package mx.itesm.minAFN.utils;

import java.util.ArrayList;
import java.util.HashSet;

import mx.itesm.minAFN.AFNState;

public class StringUtils {
	public static String join(String glue, ArrayList<String> array){
		int i= 0;
		int len = array.size();
		StringBuilder toReturn = new StringBuilder();
		if(len > 0){
			toReturn.append(array.get(0));
			while(++i<len){
				toReturn.append(glue);
				toReturn.append(array.get(i));
			}
		}
		return toReturn.toString();
	}
	
	public static String joinStateNames(String glue, ArrayList<AFNState> array){
		int i= 0;
		int len = array.size();
		StringBuilder toReturn = new StringBuilder();
		if(len > 0){
			toReturn.append(array.get(0).getStateName());
			while(++i<len){
				toReturn.append(glue);
				toReturn.append(array.get(i).getStateName());
			}
		}
		return toReturn.toString();
	}
	
	public static String join(String glue, HashSet<String> array){
		int i= 0;
		int len = array.size();
		StringBuilder toReturn = new StringBuilder();
		for (String string : array) {
			toReturn.append(string);
		}
		return toReturn.toString().substring(glue.length());
	}
}
